package com.yiren.backstage.communication.analysis;

import android.util.Log;

import com.blankj.utilcode.util.LogUtils;
import com.yiren.backstage.communication.utils.MessagesUtil;
import com.yiren.backstage.currency.constant.SignalGConstant;

/**
 * Created by WANGRONGXIANG
 * on 2022/6/13
 * Describe 通用设备信息数据分析
 */
public class PublicDeviceAnalysis {

    public void dataAnalysis(String line) {
        if (line.contains("RE_AUTH")) { // 获取验签命令
            SignalGConstant.mapValue.put(MessagesUtil.AUTH, line);
        } else if (line.contains("RE_PARAM")) { // 获取版本号命令
            if (line.contains("<") && line.contains(">") && line.indexOf("<") < line.indexOf(">")) {
                SignalGConstant.mapValue.put(MessagesUtil.PARAM, line);
            }
        } else if (line.contains("RE_REBOOT")) { // APP更新准备命令
            if (line.contains("<") && line.contains(">") && line.indexOf("<") < line.indexOf(">")) {
                SignalGConstant.mapValue.put(MessagesUtil.REBOOT, line);
            }
        } else if (line.contains("RE_UPDATE")) { // 更新APP命令
            SignalGConstant.mapValue.put(MessagesUtil.UPDATE, line);
        } else if (line.contains("RE_BBDCT") || line.contains("MP")) {// OBD车型选择
            if (line.contains("<") && line.contains(">") && line.indexOf("<") < line.indexOf(">")) {
                SignalGConstant.mapValue.put(MessagesUtil.OBD_MODELS, line);
            }
		/*} else if (line.contains("RE_ACDID")) {
			String[] split = line.toString().split(";");
			if (split.length < 4) {
				return;
			}
			SignalG.mapValue.put(Messages.SEND_STOP_DRIVING_DATA, line);*/
        } else if (line.equals("A0") || line.equals("41")) {
            Log.d("YJL", "与模块建立升级连接: " + line);
            SignalGConstant.mapValue.put(MessagesUtil.A0, line);
        } else if (line.equals("A1") || line.equals("51") || line.equals("41")) {
            Log.d("YJL", "向模块发送固件长度: " + line);
            SignalGConstant.mapValue.put(MessagesUtil.A1, line);
        } else if (line.equals("A2") || line.equals("A3") || line.equals("52") || line.equals("41")) {
            Log.d("YJL", "向模块发送一帧数据: " + line);
            SignalGConstant.mapValue.put(MessagesUtil.A2, line);
        }
    }
}
